#!/usr/bin/env bash
# rust

# f_warn 'rust: unrealized';
# echo > /dev/null;  return;

if [[ -z "${c_rust}" ]]; then
    f_info 'rust: not install';
    echo > /dev/null;  return;
fi;

ins="${INS}/rust";  ov=`cat "${ins}/.version" 2>/dev/null`;
if [[ "${ov}" = "${c_rust}" ]]; then f_info "rust: has v${c_rust}";
else
    f_wait "rust: v${c_rust}";
    d="rust-${c_rust}-x86_64-unknown-linux-gnu";
    u="https://static.rust-lang.org/dist/${d}.tar.gz";
    n="rust-${c_rust}.tgz";  f_down 'rust' "${n}" "${u}";
    rm -rf "${ins}"* || f_fail 'rust: del old';
    cd "${DEL}" || f_fail 'rust: cd to DEL';
    tar xzf "${TMP}/${n}" || f_fail 'rust: tar xzf';
    cd "${d}" || f_fail 'rust: cd to source';
    ./install.sh --prefix="${ins}" || f_fail 'rust: install';
    echo "${c_rust}" > "${ins}/.version" || f_fail 'rust: save version';
fi;

echo > /dev/null;
